<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // JavaScript会自动将基本字符串转换为字符串对象，
        // 只有将基本字符串转换为字符串对象之后才可以使用字符串对象的方法

        let str1 = "foo";//基本字符串
        let strObj = new String(str1);//转换为字符串对象
        console.log(typeof str1);//String
        console.log(typeof strObj);//Object

        // 将字符串对象转换为基本字符串
        const strObj2 = new String("haha");
        console.log(strObj2);
        let str2 = strObj2.valueOf();
        console.log(str2);
    </script>
</head>
<body>
    
</body>
</html>